//package cn.kgc.filter;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//@WebFilter(urlPatterns = "/*")
//public class FilterLogin implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpSession session = request.getSession();
//        String roles = (String) session.getAttribute("roles");
//        String uri = request.getRequestURI();
//        if(uri.indexOf("login.jsp")>-1||uri.indexOf("login")>0){
//            filterChain.doFilter(request,response);
//        }else{
//            if(roles!=null){
//                filterChain.doFilter(request,response);
//            }else {
//                response.sendRedirect("login.jsp");
//            }
//        }
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}
